package org.st.js4nk;

import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.block.BlockBreakEvent;
import cn.nukkit.event.block.BlockPlaceEvent;
import cn.nukkit.event.block.SignChangeEvent;
import cn.nukkit.event.player.*;


import java.util.HashSet;

public class JSEventListener implements Listener {
    private static HashSet<JSEvent> evetnlisteners = new HashSet<>();

    public static HashSet<JSEvent> getEvetnlisteners() {
        return evetnlisteners;
    }

    public static void registerlistener(JSEvent jsEvent) {
        evetnlisteners.add(jsEvent);
    }

    @EventHandler
    public void playerjoin(PlayerJoinEvent event) {
        for (JSEvent jsEvent : evetnlisteners) {
            jsEvent.call(event);

        }
    }
    @EventHandler
    public void playermove(PlayerMoveEvent event) {
        for (JSEvent jsEvent : evetnlisteners) {
            jsEvent.call(event);
        }
    }
    @EventHandler
    public void playerquit(PlayerQuitEvent event) {
        for (JSEvent jsEvent : evetnlisteners) {
            jsEvent.call(event);
        }
    }
    @EventHandler
    public void playertouch(PlayerInteractEvent event) {
        for (JSEvent jsEvent : evetnlisteners) {
            jsEvent.call(event);
        }
    }
    @EventHandler
    public void preloin(PlayerPreLoginEvent event){
        for (JSEvent js : evetnlisteners){
            js.call(event);
        }
    }
    @EventHandler
    public void onbreak(BlockBreakEvent event){
        for (JSEvent js : evetnlisteners){
            js.call(event);
        }
    }
    @EventHandler
    public void onplace(BlockPlaceEvent event){
        for (JSEvent js : evetnlisteners){
            js.call(event);
        }
    }
    @EventHandler
    public void onsignchange(SignChangeEvent event){
        for (JSEvent js : evetnlisteners){
            js.call(event);
        }
    }
}

